import React, { Component } from 'react';
import service from '../../api'
import { NavBar, ErrorBlock } from 'antd-mobile';
class OrderList extends Component<any, any> {
    constructor(props: any) {
        super(props)
        this.state = {
            isEmpty: true
        }
    }
    componentDidMount(): void {
        service.user.getOrderlist({ userid: localStorage.getItem('userid') }).then(res => {
            console.log(res);
            if (res.data.data.length === 0) {
                this.setState({
                    isEmpty: true
                })
            }
            else{
                this.setState({
                    isEmpty: false
                })
            }
        })
    }
    back() {
        this.props.history.replace('/index/home')
    }

    render() {
        return (
            <div className='orderlist'>
                <header>
                    <NavBar onBack={() => { this.back() }}>查看订单</NavBar>
                </header>
                {
                    this.state.isEmpty ? <> <ErrorBlock
                        image='https://gw.alipayobjects.com/zos/antfincdn/ZHrcdLPrvN/empty.svg'
                        style={{
                            '--image-height': '150px',
                        }}
                        description='订单为空'
                    >
                    </ErrorBlock>


                    </> : <></>}
            </div>
        );
    }
}

export default OrderList;